import 'package:enjoy_plus/models/house_list_model.dart';
import 'package:flutter/material.dart';

class HouseItemCard extends StatefulWidget {
  const HouseItemCard({super.key, required this.room});
  final DatumItem room;

  @override
  State<HouseItemCard> createState() => _HouseItemCardState();
}

class _HouseItemCardState extends State<HouseItemCard> {
  // 审核状态1审核中2审核成功3审核失败
  final statusColors = [
    Colors.blue,
    Colors.green,
    Colors.red,
  ];

  final statusBGColors = [
    Colors.blue.withOpacity(0.2),
    Colors.green.withOpacity(0.2),
    Colors.red.withOpacity(0.2),
  ];

  final statusTexts = [
    '审核中',
    '已绑定',
    '审核失败',
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(10),
      width: double.infinity,
      height: 120,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(widget.room.point,
                  style: const TextStyle(
                      color: Colors.black, fontWeight: FontWeight.w600)),
              Container(
                padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
                decoration: BoxDecoration(
                  color: statusBGColors[widget.room.status.toInt() - 1],
                  borderRadius: BorderRadius.circular(5),
                ),
                child: Text(statusTexts[widget.room.status.toInt() - 1],
                    style: TextStyle(
                        fontWeight: FontWeight.w500,
                        color: statusColors[widget.room.status.toInt() - 1])),
              )
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              const Text('房间号',
                  style: TextStyle(
                      color: Colors.grey, fontWeight: FontWeight.w600)),
              Text(widget.room.building + widget.room.room)
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              const Text('业主',
                  style: TextStyle(
                      color: Colors.grey, fontWeight: FontWeight.w600)),
              Text(widget.room.name)
            ],
          )
        ],
      ),
    );
  }
}
